package health.lm.com.shop.presenter;

import java.util.ArrayList;
import java.util.List;

import health.lm.com.component_base.base.mvp.contract.XPresent;
import health.lm.com.network.callback.SimpleCallBack;
import health.lm.com.shop.activity.HLPeopleActivity;
import health.lm.com.shop.entity.HLPeopleEntity;
import health.lm.com.shop.entity.MemberListResponse;
import health.lm.com.shop.model.MallModel;

import static health.lm.com.router.ARouterConstant.FROM_TYPE_INFLUENCE_TEAM;
import static health.lm.com.router.ARouterConstant.FROM_TYPE_PEOPLE_LIST;

/**
 * Created by Android Studio .
 * Project：hlian health.lm.com.shop.presenter
 * Date：2019/8/8 14:00
 * Introduce：我的人脉
 */
public class HLPeoplePresenter extends XPresent<HLPeopleActivity> {
    public void getData(String keyword, int page, int pageSize) {
        if (hasV()){
            int from_type = getV().getFrom_type();
            if (from_type == FROM_TYPE_PEOPLE_LIST) {
                MallModel.getInstance().getMyPeopleChainData(page, pageSize, keyword, new SimpleCallBack<MemberListResponse>() {
                    @Override
                    public void onSuccess(MemberListResponse pResponse) {
                        if (hasV()) getV().setNewData(pResponse.getMember_list());
                    }
                });
            } else if (from_type == FROM_TYPE_INFLUENCE_TEAM) {
                MallModel.getInstance().getInfluenceTeamData(page, pageSize, keyword, new SimpleCallBack<MemberListResponse>() {
                    @Override
                    public void onSuccess(MemberListResponse pResponse) {
                        if (hasV()) getV().setNewData(pResponse.getMember_list());
                    }
                });
            }
        }
    }

    @Deprecated
    public List<HLPeopleEntity> getDataSource() {
        List<HLPeopleEntity> entities = new ArrayList<>();
        for (int a = 0; a < 10; a++) {
            HLPeopleEntity peopleEntity = new HLPeopleEntity();
            peopleEntity.setAvatar("http://image109.360doc.com/DownloadImg/2018/03/1008/126782666_1_2018031008485635.jpeg");
            peopleEntity.setName("测试名称" + a);
            peopleEntity.setId(a);
            peopleEntity.setPhone("13112345678");
            peopleEntity.setTime("2018-08-09");
            peopleEntity.setDepartment("联络部");
            entities.add(peopleEntity);
        }
        return entities;
    }
}
